﻿using UnityEngine;
using System.Collections;
namespace FSM
{
    public class CDDelay:FSM.Action
    {
        private float usedtime;
        private float duration;
        public void SetDuratoin(float time)
        {
            duration = time;
        }
        public override void Init(params object[] param)
        {
            int l = param.Length;
            if(l > 0)
            {
                var v = param[0];
                float f = (float)(v);
                SetDuratoin(f);
            }
        }
        public CDDelay(float time)
        {
            this.duration = time;
        }
        protected override void OnEnter()
        {
            base.OnEnter();
            usedtime = 0;
        }
        protected override bool OnUpdate()
        {
            if(usedtime >= duration)
            {
                return true;
            }
            else
            {
                usedtime += Time.deltaTime;
                return false;
            }
        }
    }

}
